def isPrimer(n):
    #填写代码，判断n是否为素数
    flag = 0
    for i in range(2,n):
        if n % i == 0:
            flag = 1
    if flag == 0:
        return True
    else:
        return False
#1221
def isHui(n):
    s = str(n)
    if s == s[::-1]:
        return True
    else:
        return False


for i in range(2,1000+1):
    if isPrimer(i) and isHui(i):
        print(i)